|
What can
you name your variables? In general, variable names can be composed of
letters, numbers, and underscores (_). However, C++ reserves certain keywords
which have special meaning to the language, and you are not allowed to use
any of these keywords as variables names. Some examples of C++ keywords are int,
for, else, and class. You can, however,
use keywords in the middle of a variable name, such as "foreign" or
"classical". For a complete list of C++ keywords, please see
references on C/C++.
|
|
Programming
languages vary regarding how strict they require you to be when declaring a
variable's type. Some languages, like Perl, do not require you to announce
the type of a variable. Other languages require you to declare some variables
as numbers and others as text-strings, for example. C++, a strongly-typed
language, requires you to be even more specific than that. Instead of
declaring a variable as a number, you must say whether it will store integers
or decimals. In C++, the type of an integer is int
and the type of a decimal is float (floating-point number).
|